<html>
<head>
    <title>登录</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js">
    </script>
    <script>
    $(document).ready(function(){
        $("#login").click(function () {
            var username = $("#username").val();
            var password = $("#password").val();
            if(username != null && password != null){
                $.post("/login",
                    {
                        username: username, 
                        password: password
                    },
                    function(data, status) {
                        if (status == "success") {
                            location.href="/todo/list";
                        } else {
                            alert(status)
                            return;
                        }
                    }
                )
                .error(function() { 
                    alert("密码错误，请确认后重新尝试。"); 
                });
            }
        });
    });
    </script>
</head>
<body>
    <div align="center">
        <h4>
            账号登录
        </h4>
        <form>
            <p><input type="input" name="username" id="username"></p>
            <p><input type="password" name="password" id="password"></p>
            <p><input type="button" value="注册/登录" id="login"></p>
            <p>第一次登录会自动创建账号</p>
        </form>
    </div>
</body>
</html>